const mysql = require("mysql");
const conn = mysql.createConnection({
    host: "localhost",
    port: "3306",
    user: "root",
    password: "root",
    database: "user",
});
//连接到服务器
conn.connect();
// conn.query("select * from student", (err, result) => {
//     if (err) return console.log(err);
//     console.log(result);
// });
//-------------------------
// let sql = 'insert into student set name="hu",age=20,sex="男"';
// conn.query(sql, (err, result) => {
//     if (err) return console.log(err);
//     console.log(result);
// });
//-------------------------
// let sql = 'update student set name="李四" where id=27';
// conn.query(sql, (err, result) => {
//     if (err) return console.log(err);
//     console.log(result);
// });
//-------------------------
let sql = 'delete from student where name="张山"';
conn.query(sql, (err, result) => {
    if (err) return console.log(err);
    console.log(result);
});
//关闭连接
conn.end();